<?php

/**
 * This is the model class for table "partner_record".
 *
 * The followings are the available columns in table 'partner_record':
	 * @property integer $partner_record_id
	 * @property integer $user_id
	 * @property string $issue_user
	 * @property double $amount
	 * @property string $create_time
	 * @property string $update_time
 */
class PartnerRecord extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return PartnerRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'partner_record';
	}
	public function primaryKey()
	{
		return 'partner_record_id';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id', 'numerical', 'integerOnly'=>true),
			array('amount', 'numerical'),
			array('issue_user', 'length', 'max'=>100),
			array('create_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('partner_record_id, user_id, issue_user, amount, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'partner_record_id' =>Yii::t("PartnerRecord","Partner Record ID"),
			'user_id' =>Yii::t("PartnerRecord","User ID"),
			'issue_user' =>Yii::t("PartnerRecord","Issue User"),
			'amount' =>Yii::t("PartnerRecord","Amount"),
			'create_time' =>Yii::t("PartnerRecord","Create Time"),
			'update_time' =>Yii::t("PartnerRecord","Update Time"),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('partner_record_id',$this->partner_record_id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('issue_user',$this->issue_user,true);
		$criteria->compare('amount',$this->amount);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'sort'=>array(  
           		 'defaultOrder'=>'partner_record_id DESC',  
       		 ),  
       		'pagination'=>array(  
           		 'pageSize'=>20  
       		 ),  
		));
	}
}